<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>中文卡片翻转游戏</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <script src="https://unpkg.com/vue@3"></script>
    
    <!-- Tailwind 配置 -->
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#165DFF',
                        secondary: '#36CFC9',
                        accent: '#FF7D00',
                        dark: '#1D2129',
                        light: '#F2F3F5'
                    },
                    fontFamily: {
                        sans: ['Inter', 'system-ui', 'sans-serif'],
                    },
                    animation: {
                        'float': 'float 3s ease-in-out infinite',
                        'pulse-slow': 'pulse 4s cubic-bezier(0.4, 0, 0.6, 1) infinite',
                    },
                    keyframes: {
                        float: {
                            '0%, 100%': { transform: 'translateY(0)' },
                            '50%': { transform: 'translateY(-10px)' },
                        }
                    }
                },
            }
        }
    </script>
    
    <!-- 引入外部CSS -->
    <link rel="stylesheet" href="src/css/styles.css">
</head>
<body class="bg-blue-50 bg-pattern min-h-screen font-sans text-dark overflow-x-hidden">
    <div id="app">
        <!-- 顶部导航 -->
        <header class="bg-white/90 backdrop-blur-md shadow-sm sticky top-0 z-50 transition-all duration-300" :class="{ 'py-2 shadow': isScrolled, 'py-4': !isScrolled }">
            <div class="container mx-auto px-4 py-4 flex flex-col items-center">
                <div class="flex items-center space-x-2 mb-3">
                    <i class="fa fa-clone text-primary text-2xl"></i>
                    <h1 class="text-xl md:text-2xl font-bold">中文卡片翻转</h1>
                </div>
                
                <!-- 游戏模式标签页 -->
                <div class="flex rounded-full bg-gray-100 p-1 mb-3">
                    <button 
                        class="px-5 py-1.5 rounded-full text-sm font-medium transition-all duration-300"
                        :class="{ 'bg-primary text-white shadow-sm': currentGameMode === 'cards', 'text-gray-700': currentGameMode !== 'cards' }"
                        @click="switchGameMode('cards')"
                    >
                        卡片翻转
                    </button>
                    <button 
                        class="px-5 py-1.5 rounded-full text-sm font-medium transition-all duration-300"
                        :class="{ 'bg-primary text-white shadow-sm': currentGameMode === 'polyhedron', 'text-gray-700': currentGameMode !== 'polyhedron' }"
                        @click="switchGameMode('polyhedron')"
                    >
                        多面体旋转
                    </button>
                </div>
                
                <div class="flex items-center space-x-4 w-full justify-between">
                    <div class="flex items-center space-x-1 text-sm">
                        <i class="fa fa-check-circle text-accent"></i>
                        <span id="flipped-count" class="font-medium">{{ flippedCards }}</span>
                        <span>/</span>
                        <span id="total-count" class="font-medium">{{ totalCards }}</span>
                    </div>
                    <button id="refresh-btn" class="p-3 rounded-full hover:bg-gray-100 transition-colors touch-feedback" @click="newGame" @touchstart="newGame">
                        <i class="fa fa-refresh text-primary text-lg"></i>
                    </button>
                </div>
            </div>
        </header>
        
        <!-- 根据当前游戏模式显示对应内容 -->
        <div v-if="currentGameMode === 'cards'">
            <!-- 原有的卡片游戏内容 -->
            <main class="container mx-auto px-4 py-8 md:py-16">
                <!-- 游戏信息 -->
                <div class="text-center mb-8 md:mb-12">
                    <h2 class="text-[clamp(1.5rem,3vw,2.5rem)] font-bold mb-3 text-dark">卡片翻转挑战</h2>
                    <p class="text-gray-600 max-w-2xl mx-auto">点击卡片翻转查看中文内容，挑战你的记忆力！</p>
                </div>

                <!-- 卡片容器 -->
                <div id="card-container" class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-4 md:gap-6 mb-10">
                    <div v-for="(card, index) in cards" :key="card.id" 
                         class="card-flip w-full aspect-square cursor-pointer animate-float touch-feedback card-shadow-hover" 
                         :class="{ 'flipped': card.flipped, 'shine-effect': card.isShining, 'glow-effect': card.isGlowing }" 
                         :style="{ animationDelay: `${index * 0.1}s` }" 
                         @click="flipCard(card)" 
                         @touchstart="flipCard(card)">
                        <div class="card-inner relative w-full h-full rounded-xl shadow-lg">
                            <!-- 卡片背面 -->
                            <div class="card-back absolute inset-0 bg-gradient-to-br flex flex-col items-center justify-center p-4 text-white" :class="card.color">
                                <i class="fa fa-question-circle text-4xl mb-2"></i>
                                <span class="text-sm font-medium">点击翻转</span>
                                <div class="absolute inset-0 bg-white/10 rounded-xl"></div>
                            </div>
                            
                            <!-- 卡片正面 -->
                            <div class="card-front absolute inset-0 bg-gradient-to-br from-white to-gray-100 flex items-center justify-center p-6 rounded-xl">
                                <div class="text-center">
                                    <h3 class="text-2xl md:text-3xl font-bold text-dark">{{ card.text }}</h3>
                                </div>
                                <div class="absolute top-3 right-3 text-primary/70">
                                    <i class="fa fa-check-circle"></i>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 控制按钮 -->
                <div class="text-center mt-8">
                    <button id="new-game-btn" 
                            class="bg-primary hover:bg-primary/90 text-white font-medium py-4 px-10 rounded-full shadow-lg hover:shadow-xl transform transition-all duration-300 flex items-center justify-center mx-auto touch-feedback" 
                            :class="{ 'scale-95': isButtonPressed }" 
                            @click="newGame" 
                            @touchstart="newGame">
                        <i class="fa fa-random mr-2"></i>
                        <span>新游戏</span>
                    </button>
                </div>

                <!-- 卡片类别选择 -->
                <div class="mt-10 max-w-3xl mx-auto">
                    <h3 class="text-center text-lg font-semibold mb-4">选择卡片类别</h3>
                    <div class="flex flex-wrap justify-center gap-3" id="category-buttons">
                        <button v-for="(category, key) in cardCategories" :key="key" 
                                class="px-5 py-3 rounded-full text-sm font-medium transition-all duration-300 touch-feedback" 
                                :class="{ 'bg-primary text-white shadow-md': currentCategory === key, 'bg-white text-gray-700 hover:bg-gray-100': currentCategory !== key }" 
                                @click="changeCategory(key)" 
                                @touchstart="changeCategory(key)">
                            {{ category.name }}
                        </button>
                    </div>
                </div>
            </main>

            <!-- 页脚 -->
            <footer class="bg-white/90 backdrop-blur-md mt-16 py-6">
                <div class="container mx-auto px-4 text-center text-gray-500 text-sm">
                    <p>© 2025 中文卡片翻转游戏 | 点击卡片查看内容</p>
                </div>
            </footer>
        </div>
        
        <!-- 多面体游戏内容 -->
        <div v-else-if="currentGameMode === 'polyhedron'" class="container mx-auto px-4 py-8 md:py-16">
            <div class="text-center mb-8 md:mb-12">
                <h2 class="text-[clamp(1.5rem,3vw,2.5rem)] font-bold mb-3 text-dark">多面体旋转挑战</h2>
                <p class="text-gray-600 max-w-2xl mx-auto">点击按钮旋转多面体，学习显示的中文词汇！</p>
            </div>
            
            <!-- 多面体容器 -->
            <div class="flex flex-col items-center justify-center mb-10">
                <div class="perspective-1000 w-64 h-64 md:w-80 md:h-80 relative" ref="polyhedronContainer">
                    <div class="polyhedron relative w-full h-full transform-style-3d transition-transform-1000" :style="{ transform: polyhedronTransform }">
                        <!-- 多面体的各个面 -->
                        <div v-for="(face, index) in polyhedronFaces" :key="index" 
                             class="absolute inset-0 flex items-center justify-center p-6 rounded-lg shadow-lg bg-gradient-to-br text-white text-center transition-opacity-300" 
                             :class="face.color"
                             :style="getFaceStyle(index)">
                            <h3 class="text-2xl md:text-3xl font-bold">{{ face.text }}</h3>
                        </div>
                    </div>
                </div>
                
                <!-- 旋转按钮 -->
                <button id="rotate-polyhedron-btn" 
                        class="mt-10 bg-primary hover:bg-primary/90 text-white font-medium py-4 px-10 rounded-full shadow-lg hover:shadow-xl transform transition-all duration-300 flex items-center justify-center mx-auto touch-feedback"
                        :class="{ 'scale-95': isRotating }"
                        @click="rotatePolyhedron"
                        :disabled="isRotating">
                    <i class="fa fa-refresh mr-2"></i>
                    <span>{{ isRotating ? '旋转中...' : '旋转多面体' }}</span>
                </button>
            </div>
            
            <!-- 显示历史记录 -->
            <div class="max-w-2xl mx-auto mt-12">
                <h3 class="text-center text-lg font-semibold mb-4">最近显示的词汇</h3>
                <div class="flex flex-wrap justify-center gap-2">
                    <span v-for="(item, index) in recentItems" :key="index" 
                          class="px-3 py-1 bg-white rounded-full shadow-sm text-sm">
                        {{ item }}
                    </span>
                </div>
            </div>
        </div>
        
        <!-- 页脚 -->
        <footer class="bg-white/90 backdrop-blur-md mt-16 py-6">
            <div class="container mx-auto px-4 text-center text-gray-500 text-sm">
                <p>© 2025 中文卡片翻转游戏 | 点击卡片查看内容</p>
            </div>
        </footer>
    </div>

    <!-- 引入外部JavaScript -->
    <script src="src/data/cardData.js"></script>
    <script src="src/js/app.js"></script>
</body>
</html>